<!--
 * @Description: 首页组件
 * @Author: hai-27
 * @Date: 2020-02-07 16:23:00
 * @LastEditors: hai-27
 * @LastEditTime: 2020-02-27 13:36:12
 -->
<template>
  <div class="home" id="home" name="home">
    <!-- 轮播图 -->
    <div class="block">
      <el-carousel height="460px">
        <!-- <el-carousel-item v-for="item in carousel" :key="item.carousel_id">
          <img
            style="height: 460px"
            :src="$target + item.imgPath"
            :alt="item.describes"
          />
        </el-carousel-item> -->
        <el-carousel-item>
          <img
            style="height: 460px"
            src="https://www.fendi.cn/pub/media/CMS/block/homepage/baguette-hero-video_desktop.jpg"
          />
        </el-carousel-item>
      </el-carousel>
    </div>
    <!-- 轮播图END -->
    <div class="main-box">
      <div class="main">
 
      </div>
    </div>
  </div>
</template>
<script>
import {
  AdminQueryAllGoods,
  queryParentGoods,
  querySomeGoodsByType,
} from "../api/index";
export default {
  data() {
    return {
      allgoodstype: [], // 所有商品分类
      carousel: "", // 轮播图数据
      phoneList: "", // 手机商品列表
      digitallist: "", //数码商品列表
      Beautylist: "", //美妆商品列表
      dbagsllist: "", //箱包商品列表
      djewelrylist: "", //首饰商品列表
      testdata: [ // 测试假数据
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id: 1,
        },
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id: 2,
        },
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id: 3,
        },
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id: 4,
        },
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id: 5,
        },
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id: 6,
        },
        {
          goodsAuthCode: 12564,
          goodsBrand: 7981,
          goodsCount: 1000,
          goodsDescribed: "能够提升气色",
          goodsId: 10082,
          goodsImg: "/e:/imgs.png",
          goodsName: "CHANEL香奈儿炫亮魅力丝绒唇膏狮子系列 口红58",
          goodsOrgin: "法国",
          goodsPrice: 759,
          goodsPutaway: "2021-03-02",
          goodsSellingPrice: 1089,
          goodsStatus: 1,
          goodsTimes: "2020-12-09",
          goodsType: 77,
          id:7,
        },
        
      ],
    };
  },
  watch: {

  },
  created() {
    this.init();
  },
  mounted() {
    this.getdigitalGoods(),
      this.getBeautyGoods(),
      this.getdbagsGoods(),
      this.getdjewelryGoods();
  },
  methods: {
    // 获取数据测试
    init() {
      let params = {
        pageNum: 1,
        pageSize: 10,
      };
      AdminQueryAllGoods({ ...params })
        .then((res) => {
          this.phoneList = res.data.list;
        })
        .catch((err) => {
          console.log(err);
        });
      // 获取全部商品的分类列表
      queryParentGoods()
        .then((res) => {
          this.allgoodstype = res.data.slice(0, 4); // 获取前四个做首页渲染
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 数码数据
    getdigitalGoods() {
      let params = {
        goodsType: 106,
        pageNum: 1,
        pageSize: 7,
      };
      querySomeGoodsByType({ ...params })
        .then((res) => {
          this.digitallist = res.data.list.splice(0,7);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 美妆数据
    getBeautyGoods() {
      let params = {
        goodsType:77,
        pageNum: 1,
        pageSize: 7,
      };
      querySomeGoodsByType({ ...params })
        .then((res) => {
          this.Beautylist = res.data.list.splice(0,7);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 箱包数据
    getdbagsGoods() {
      let params = {
        goodsType: 75,
        pageNum: 1,
        pageSize: 2,
      };
      querySomeGoodsByType({ ...params })
        .then((res) => {
          this.dbagsllist = res.data.list.splice(0,7);
        })
        .catch((err) => {
          console.log(err);
        });
    },
    // 首饰数据
    getdjewelryGoods() {
      let params = {
        goodsType: 94,
        pageNum: 1,
        pageSize: 7,
      };
      querySomeGoodsByType({ ...params })
        .then((res) => {
          this.djewelrylist = res.data.list.splice(0,7);
        })
        .catch((err) => {
          console.log(err);
        });
    },
  },
};
</script>
<style scoped>
@import "../assets/css/index.css";
</style>